package work.igames.vertxcreate.common;

import lombok.Data;
import lombok.experimental.Accessors;
import work.igames.vertxcreate.constant.StateEnum;

import java.io.Serializable;

/**
 * @ClassName CommonResult
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2020/11/2 上午11:55
 * @Version V1.0
 * @Since JDK 11
 */
@Data
@Accessors(chain = true)
public class CommonResult<T> implements Serializable {

    private long code;

    private String msg;

    private T data;

    public static <T> CommonResult<T> create(T data, StateEnum stateEnum){
        return new CommonResult<T>().setData(data).setMsg(stateEnum.msg).setCode(stateEnum.code);
    }
}
